<extend name="template/base_index" />


<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
    <link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css" />

    <script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
    <script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/localization/messages_zh.min.js"></script>
    <style type="text/css">
.pt8{width:2rem !important;padding-top: 8px;}
input.error {border: 1px solid red;}
label.checked {padding-left: 25px;}
label.error {padding-left: 25px;padding-bottom: 2px;font-weight: bold;color: #EA5200;}
    </style>

</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <!-- 带验证 form -->
            <form id="gameForm" class="form-horizontal well validateForm">
                <fieldset>
                    <legend>#积分商品# 添加</legend>
                    <div class="form-group">
                        <label for="inputname" class="col-md-2 col-lg-2 control-label">商品名</label>
                        <div class="col-md-4 col-lg-4">
                            <input type="text" class="required form-control input-normal" name="name" id="inputname" placeholder="{:L('PLACEHOLDER_TITLE')}">
                        </div>
                        <div class="col-md-2 col-lg-2">
                            <div class="help-block">(商品名)</div>
                        </div>
                    </div>
                    <div class="form-group">
                      <label for="inputnumber" class="col-md-2 col-lg-2 control-label">商品数量</label>

                      <div class="col-md-2 col-lg-2">
                          <input type="text" class="required form-control  input-number" name="number" aria-label="" value="0">
                      </div>
                      <div class="col-md-5 col-lg-5">件 
                          <div class="help-block">(0代表无限)</div>
                      </div>
                    </div>
                    <div class="form-group">
                        <label for="inputcnt" class="col-md-2 col-lg-2 control-label">描述</label>
                        <div class="col-md-8 col-lg-8">
                            <textarea name='detail'  style="height:300px" id="detail"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <input type="hidden" name="main_img" id="prizeIcon">
                        <label for="" class="col-md-2 col-lg-2 control-label">图标主图</label>
                        <div class="col-lg-10 col-md-10">
                            <span class="text-muted">(建议尺寸为400像素*400像素，大小不超过500kb)<i data-toggle="tooltip" class="fa fa-question" title="图标将会在抽奖页面显示"></i></span>
<!-- 图片选择DOM结构 -->
                                <div class="wxuploaderimg clearfix main_img"  data-maxitems="1">
                                    <div class="img-preview clearfix" >
                                    </div>
                                    <div class="add">
                                        <i class="fa fa-plus"></i>
                                    </div>
                                </div>
<!-- 图片选择DOM结构 -->
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-md-2 col-lg-2 control-label">兑换积分</label>
                        <div class="col-md-2 col-lg-2 input-number">
                            <input size="12" type="text" class="required form-control input-number" name=" score" id="inputscore" value="1" >
                        </div>
                        <div class="col-md-6 col-lg-6">积分
                            <div class="help-block">(1+,正整数)</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-md-2 col-lg-2 control-label">兑换金额</label>
                        <div class="col-md-2 col-lg-2  input-number">
                            <input class="required form-control input-number inputspin" name="price" id="price" type="text" size="12" value="0"/>
                        </div>
                        <div class="col-md-6 col-lg-6">RMB
                            <div class="help-block">(0+,保留2位小数点)</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-md-2 col-lg-2 control-label">状态</label>
                        <div class="col-md-10 col-lg-10  input-number">
                            <input type="radio" class="" name="onshelf" id="" value="0">下架
                            <input type="radio" name="onshelf" id="" value="1" checked="checked">上架
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="btns" class="col-md-2 col-lg-2 control-label">&nbsp;</label>
                        <div class="col-lg-10 col-md-10">
                            <a target-form="validateForm" class="ajax-post btn btn-primary" href="{:U(CONTROLLER_NAME.'/add',array('gid'=>$game['id']))}" autofocus="autofocus"  data-loading-text="{:L('BTN_SAVE')}..." ><i class="fa fa-save"></i> {:L('BTN_SAVE')}</a>
                            <a class="btn btn-default" href="{:U(CONTROLLER_NAME.'/index')}"><i class="fa fa-times-circle"></i> {:L('BTN_CANCEL')}</a>
                        </div>
                    </div>
                </fieldset>
            </form>
            <!-- form -->
        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
    <include file="template/prizepicture" />
</block>

<block name="area_footer">
    <script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
    <script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
    <script type="text/javascript" src="/Public/Upload/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" src="/Public/Upload/ueditor/1.4.3/ueditor.all.min.js"></script>
    <script src="__CDN__/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js"></script>
    <script type="text/javascript">
        $(function() {
            var ue = UE.getEditor('detail',{
                toolbars: [
                   ['fullscreen', 'source', 'undo', 'redo', 'bold','italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', '|','lineheight'
       , 'fontsize', 'insertimage','emotion','link', 'unlink', 'anchor', '|','map','print', 'preview',  'drafts','forecolor','backcolor'
        ]
                ]
                // ,initialFrameWidth:1000
                ,initialFrameHeight:300
                ,autoHeightEnabled:false
            });
            //图片上传
            wxuploadimg.init({cont:".wxuploaderimg"});

            // $(".inputspin").TouchSpin({initval: 0});
            $(".validateForm").validate();
            // $("#gameForm").validate({
            //     errorPlacement: function(error, element) {
            //         $(".checked", element.parent()).remove();
            //         error.appendTo(element.parent());
            //     },
            //     success: function(label) {
            //         label.removeClass("error").addClass("checked").text("验证成功!");
            //     },
            //     rules: {
            //         name: {
            //             required: true,
            //             remote: {
            //                 url: "{:U('Game/check_name')}"
            //             }
            //         }
            //     }
            // }) //end validate
        }); //end ready
    </script>
</block>